package com.cn.wanxi.service;

import com.cn.wanxi.dao.CompanyDao;
import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.util.IO;
import com.cn.wanxi.util.PAHT;
import com.cn.wanxi.util.Tool;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;

/**
 * 控制公司信息层
 */
public class CompanyService {
    private String split = PAHT.SPLIT.getPath();
    /**
     * 得到ContactUs页面 地图左边公司信息
     * @return
     */
    public CompanyModel getContactUsCompanyInformationModel() {
        List<String> contactUsCompanyList = new ArrayList<>();
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        contactUsCompanyList.add(companyDao.getContactUsPhoneImg());
        contactUsCompanyList.add(companyDao.getContactUsPhone());
        contactUsCompanyList.add(companyDao.getContactUsAddressImg());
        contactUsCompanyList.add(companyDao.getContactUsAddress());
        contactUsCompanyList.add(companyDao.getContactUsFaxImg());
        contactUsCompanyList.add(companyDao.getContactUsFax());
        contactUsCompanyList.add(companyDao.getContactUsMailboxImg());
        contactUsCompanyList.add(companyDao.getContactUsMailbox());
        contactUsCompanyList.add(companyDao.getContactUsRouteImg());
        contactUsCompanyList.add(companyDao.getContactUsRoute());
        contactUsCompanyList.add(companyDao.getContactUsRouteImg2());
        contactUsCompanyList.add(companyDao.getContactUsRoute2());
        String SontactUsCompany = Tool.replaceText(contactUsCompanyList.toString());
        IO.writeNotepad(SontactUsCompany, PAHT.COMPANY_FILE_NAME.getPath());
        String[] str = IO.readNotepad().split(",");
        companyModel.setContactUsPhoneImg(str[0]);
        companyModel.setContactUsPhone(str[1]);
        companyModel.setContactUsAddressImg(str[2]);
        companyModel.setContactUsAddress(str[3]);
        companyModel.setContactUsFaxImg(str[4]);
        companyModel.setContactUsFax(str[5]);
        companyModel.setContactUsMailboxImg(str[6]);
        companyModel.setContactUsMailbox(str[7]);
        companyModel.setContactUsRouteImg(str[8]);
        companyModel.setContactUsRoute(str[9]);
        companyModel.setContactUsRouteImg2(str[10]);
        companyModel.setContactUsRoute2(str[11]);
        return companyModel;
    }

    /**
     *  得到联系我们大图(新.包括小图片)
     * @return
     */
    public CompanyModel getContactUsImgCompanyModel() {
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        String ContactUsImgCompany = companyDao.getContactUsImg2()+","+companyDao.getContactUsImg();
        IO.writeNotepad(ContactUsImgCompany, PAHT.COMPANY_FILE_NAME.getPath());
        String[] str = IO.readNotepad().split(",");
        companyModel.setContactUsImg2(str[0]);
        companyModel.setContactUsImg(str[1]);
        return companyModel;
    }

    /**
     * 得到在线联系页面大图
     * @return
     */
    public CompanyModel getOnlineImgCompanyModel() {
        String onlineImgCompany;
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        onlineImgCompany = companyDao.getOnlineReservationsImg();
        IO.writeNotepad(onlineImgCompany, PAHT.COMPANY_FILE_NAME.getPath());
        String str = IO.readNotepad();
        companyModel.setOnlineReservationsImg(str);
        return companyModel;
    }

    /**
     *  得到关于我们页面大图
     * @return
     */
    public CompanyModel getAboutUsImgCompanyModel() {
        String aboutUsImgCompany;
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        aboutUsImgCompany = companyDao.getAboutUsImg1();
        IO.writeNotepad(aboutUsImgCompany, PAHT.COMPANY_FILE_NAME.getPath());
        String str = IO.readNotepad();
        companyModel.setAboutUsImg1(str);
        return companyModel;
    }

    /**
     *  得到home页面 logo 电话 邮箱
     * @return
     */
    public CompanyModel getCompanyModel() {
        String homeTop;
        String[] str;
        CompanyDao companyDao = new CompanyDao();
        homeTop = companyDao.getLogo()+",";
        homeTop+=companyDao.getMailbox()+",";
        homeTop+=companyDao.getPhone();
        IO.writeNotepad(homeTop, PAHT.COMPANY_FILE_NAME.getPath());
        str = IO.readNotepad().split(",");
        CompanyModel companyModel = new CompanyModel();
        companyModel.setLogo(str[0]);
        companyModel.setMailbox(str[1]);
        companyModel.setPhone(str[2]);
        return companyModel;
    }

    /**
     * 得到关于我们信息
     * @return
     */
    public CompanyModel getCompanyModel2() {
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        String Company = companyDao.getIntermediateImg()+","+companyDao.getIntermediateAbout();
        IO.writeNotepad(Company, PAHT.COMPANY_FILE_NAME.getPath());
        String[] str = IO.readNotepad().split(",");
        companyModel.setIntermediateImg(str[0]);
        companyModel.setIntermediateAbout(str[1]);
        return companyModel;
    }

    /**
     * 得到公司理念
     * @return
     */
    public CompanyModel getCompanyModelIdea() {
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        String Company = companyDao.getIdeaImg()+split
                +companyDao.getIdeaTextTitle()+split
                +companyDao.getIdeaText()+split
                +companyDao.getIdeaImg2()+split
                +companyDao.getIdeaTextTitle2()+split
                +companyDao.getIdeaText2();
        IO.writeNotepad(Company, PAHT.COMPANY_FILE_NAME.getPath());
        String[] str = IO.readNotepad().split(split);
        companyModel.setIdeaImg(str[0]);
        companyModel.setIdeaTextTitle(str[1]);
        companyModel.setIdeaText(str[2]);
        companyModel.setIdeaImg2(str[3]);
        companyModel.setIdeaTextTitle2(str[4]);
        companyModel.setIdeaText2(str[5]);
        return companyModel;
    }

    /**
     * 得到联系我们
     * @return
     */
    public CompanyModel getCompanyModelContactDetails() {
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        String Company = companyDao.getIntermediateImg2()+split
                +companyDao.getPhoneImg()+split
                +companyDao.getPhone2()+split
                +companyDao.getIntermediateMailboxImg()+split
                +companyDao.getIntermediateMailbox()+split
                +companyDao.getFaxImg()+split
                +companyDao.getFax()+split
                +companyDao.getAddressImg()+split
                +companyDao.getAddress();
        IO.writeNotepad(Company, PAHT.COMPANY_FILE_NAME.getPath());
        String[] str = IO.readNotepad().split(split);
        companyModel.setIntermediateImg2(str[0]);
        companyModel.setPhoneImg(str[1]);
        companyModel.setPhone2(str[2]);
        companyModel.setIntermediateMailboxImg(str[3]);
        companyModel.setIntermediateMailbox(str[4]);
        companyModel.setFaxImg(str[5]);
        companyModel.setFax(str[6]);
        companyModel.setAddressImg(str[7]);
        companyModel.setAddress(str[8]);
        return companyModel;
    }

    /**
     * 得到底部咨询热线
     * @return
     */
    public CompanyModel getCompanyModelbottom() {
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        String Company =companyDao.getInformationHotline()+split+companyDao.getCopyright();
        IO.writeNotepad(Company, PAHT.COMPANY_FILE_NAME.getPath());
        String[] str = IO.readNotepad().split(split);
        companyModel.setInformationHotline(str[0]);
        companyModel.setCopyright(str[1]);
        return companyModel;
    }

    /**
     * /获取关于我们数据的实例
     * @return
     */
    public CompanyModel getAboutUsImg2CompanyModel() {
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        String Company =companyDao.getAboutUsImg2()+split+companyDao.getAboutUsImgtext();
        IO.writeNotepad(Company, PAHT.COMPANY_FILE_NAME.getPath());
        String[] str = IO.readNotepad().split(split);
        companyModel.setAboutUsImg2(str[0]);
        companyModel.setAboutUsImgtext(str[1]);
        System.out.println(str[0]);
        System.out.println(str[1]);
        return companyModel;
    }

    /**
     * /获取新闻数据的实例
     * @return
     */
    public CompanyModel getNewsCompanyModel() {
        String company;
        CompanyModel companyModel = new CompanyModel();
        CompanyDao companyDao = new CompanyDao();
        company = companyDao.getNewsImg();
        IO.writeNotepad(company, PAHT.COMPANY_FILE_NAME.getPath());
        String str = IO.readNotepad();
        companyModel.setNewsImg(str);
        return companyModel;
    }

}
